package com.sample.service;

import java.util.List;

import com.sample.model.User;
import com.trg.search.SearchResult;
import com.trg.search.flex.FlexSearch;

public interface UserService {

	public User fetchByLoginAndPassword(String login, String password);
	
	public User fetchUserByLogin(String login);
	
	public User addUser(User user, String password);
	
	public void changePassword(Long userId, String newPassword);
	
	
	/**
	 * Delete the User with the specified id from the database.
	 */
	public boolean deleteById(Long id);

	/**
	 * Delete the specified User from the database.
	 */
	public boolean deleteEntity(User user);

	/**
	 * Get the User with the specified id from the database.
	 */
	public User fetch(Long id);

	/**
	 * Get a list of all the Users.
	 */
	public List<User> fetchAll();

	/**
	 * Update the corresponding User in the database with the properties of
	 * the specified object. The corresponding User is determined by id.
	 */
	public void update(User user);

	/**
	 * Search for Users given the search parameters in the
	 * specified <code>Search</code> object.
	 */
	public List<User> search(FlexSearch options);

	/**
	 * Returns the total number of results that would be returned using the
	 * given <code>Search</code> if there were no paging or maxResult limits.
	 */
	public int count(FlexSearch options);

	/**
	 * Returns a <code>SearchResult</code> object that includes the list of
	 * results like <code>search()</code> and the total length like
	 * <code>searchLength</code>.
	 */
	public SearchResult<User> searchAndCount(FlexSearch options);

	/**
	 * Returns true if the object is connected to the current hibernate session.
	 */
	public boolean isConnected(Object object);

	/**
	 * Flushes changes in the hibernate cache to the database. 
	 */
	public void flush();
}
